/* 
 * File:   ClientHandler.h
 * Author: Lance
 *
 * Created on September 30, 2012, 12:24 PM
 */

#ifndef CLIENTHANDLER_H
#define	CLIENTHANDLER_H
#include "UserMessages.h"
#include <string.h>
#include <errno.h>
#include <map>
#include <vector>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sstream>
#include <iostream>

using namespace std;

class ClientHandler {
public:
	ClientHandler(int client_socket);
	ClientHandler(const ClientHandler& orig);
	virtual ~ClientHandler();
	void handle();
	bool debug;
private:
	bool handleRequests(int c);
	char * readRequest(int c);
	char * readRequest(int c, bool recursive);
	void sendResponse(string response);
	string stripCommand(string * command);
	void respondList(string message);
	void respondGet(string message);
	void respondPut(string message);
	bool containsNewLine(string * str);
	
	int client_socket;
	UserMessages * messageCenter;
};

#endif	/* CLIENTHANDLER_H */

